#####################################
# CMakeLists.txt file
# author: 	jiyingliang
# email : 	jiyingliang@hisense.com
# date  :	2020.10.23
#####################################
cmake_minimum_required(VERSION 3.6)
project(PathPlanner)

OPTION(TEST  "Test compile" ON)
add_compile_options(-std=c++14 -Wno-psabi -Wl,-z,multidefs)
#add user data surpport for mongoose
if (TEST)
	add_definitions(-DTEST_MODE)
endif()
#set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc)
#set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)
find_package(ompl)

include_directories(
	inc/
	lib/AiBox_LOG/
	lib/cJson
	/usr/include/
	${OMPL_INCLUDE_DIRS}
	${MOSQUITTO_INCLUDE_DIRS}
)
FILE (GLOB SRC_LISTS 
	src/*.cpp
	lib/cJson/*.c
)
link_directories(
	${CMAKE_SOURCE_DIR}/build/
	${CMAKE_SOURCE_DIR}/lib/
	${OMPL_LIBRARIES_DIRS}
	/usr/lib/x86_64-linux-gnu/
)
add_library(${PROJECT_NAME} SHARED ${SRC_LISTS})

if (TEST)
	add_library("${PROJECT_NAME}_a" STATIC ${SRC_LISTS})
	message("build test app")
	add_executable("path_planner" main/main.cpp)
	target_link_libraries("path_planner"  PRIVATE 
		"${PROJECT_NAME}_a"
		pthread
		mosquitto
		ompl
	)
endif()

install(TARGETS path_planner DESTINATION /usr/local/bin)
install(PROGRAMS ${CMAKE_SOURCE_DIR}/script/RunMosquitto.sh   DESTINATION /usr/local/bin)
install(PROGRAMS  ${CMAKE_SOURCE_DIR}/script/RunPlanner.sh   DESTINATION /usr/local/bin)